package com.fengye.resign.controller;

import com.fengye.common.constants.AppHttpCodeEnum;
import com.fengye.common.controller.BaseController;
import com.fengye.common.domain.ResponseResult;
import com.fengye.common.domain.dto.ResignIpaDto;
import com.fengye.common.utils.ResignUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

/**
 * @author sunlei
 * @version 1.0
 * @date 2024/5/20 09:50:43
 * @description 重签名苹果ipa包控制器
 */

@Api(tags = "重签名模块")
@RestController
@RequestMapping("/resign")
@CrossOrigin
@Slf4j
public class ResignController extends BaseController {
    @RequestMapping(value = "/ipa", method = {RequestMethod.POST})
    public ResponseResult<Void> resignIpa(@Valid @RequestBody ResignIpaDto resignIpaDto) {
        boolean resignIpa = ResignUtils.resignIpa(resignIpaDto);
        log.info("resignIPA = " + resignIpa);
        if (!resignIpa) {
            return ResponseResult.fail(AppHttpCodeEnum.RESIGN_IPA_ERROR);
        }

        return ResponseResult.success("重签名成功");
    }
}
